home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93a.txt / 000019_icon-group-sender _Fri Jan 15 13:22:44 1993.msg < prev    next >
Internet Message Format  |  1993-04-21  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 15 Jan 1993 20:15:40 MST
  2. Date: Fri, 15 Jan 93 13:22:44 PST
  3. From: alex@laguna.Metaphor.COM (Bob Alexander)
  4. Message-Id: <9301152122.AA04938@laguna.Metaphor.COM>
  5. To: icon-group@cs.arizona.edu
  6. Subject: Re: Pattern matching in Icon?
  7. Status: R
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9.  
  10. Wow, this seems to be a difficult concept to communicate!  However,
  11. considering your last communication, I think my code fragment does what
  12. you want, in current Icon, without muddying things up very much.  Let
  13. me re-state it with some clarifying additions:
  14.  
  15.     record syntax_tree(operator, arguments)
  16.     ...
  17.     case type(s) || "::" || s[1] of {    # create a key with s's data type
  18.                              # ("syntax_tree") and the operator
  19.  
  20.       "syntax_tree::let": {        # execute this code if the "type"
  21.                     # is "syntax_tree" and the operator
  22.                     # is "let"
  23.     s.arguments := a         # assign "a" to the "arguments" field
  24.     ...                 # etc.
  25.       } 
  26.       "syntax_tree::apply": {         # etc.
  27.     s.arguments := a 
  28.     ... 
  29.     }
  30.  
  31. (The "::" is an arbitrary separator).  This permanently assigns to the
  32. arguments field of "s" -- if that's not okay it could be made
  33. "temporary" by working on a copy of s.
  34.  
  35. Am I still missing the point?
  36.  
  37.  
  38. -- Bob Alexander
  39.  
  40. Metaphor Computer Systems     (415) 966-0751      alex@metaphor.com
  41. ====^=== Mountain View, CA  ...{uunet}!{decwrl,apple}!metaphor!alex
  42.